/* eslint-disable no-extra-parens */
import { InitModalMethod, ParseModalMethod } from './defination';

/**
 * 设置表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const initModalData = (form = {}, workstep = {}, tts = false) => {
	if (!form || !workstep || !workstep.do) {
		return;
	}
	form.name = workstep.name;
	// yes
	form.nextStepYes = workstep.answer[0]?.do?.id;

	// no
	form.nextStepNo = workstep.answer[1]?.do?.id;
};
InitModalMethod['stopSystemRecording'] = initModalData;

/**
 * 解析表单属性
 * @param { Object } form 表单数据
 * @param { Object } workstep cached的ai工作流
 */
export const parseModalData = (form = {}, workstep = {}, tts = false) => {
	console.log(form, workstep);
	if (!form || !workstep || !workstep.do) {
		return;
	}

	// yes
	workstep.answer[0].do = Object.assign({}, workstep.answer[0].do);
	workstep.answer[0].do.id = form.nextStepYes;
	workstep.answer[0].do.no = form.nextStepYes;
	delete workstep.answer[0].after;

	// no
	workstep.answer[1].do = Object.assign({}, workstep.answer[1].do);
	workstep.answer[1].do.id = form.nextStepNo;
	workstep.answer[1].do.no = form.nextStepNo;
	delete workstep.answer[1].after;

	workstep.name = form.name;
};
ParseModalMethod['stopSystemRecording'] = parseModalData;
/**
// 结束双录
"stopSystemRecording":{
    "type":"stopSystemRecording",
    "do":{
        "command": "stopSystemRecording"
    },
    "answer": [
        {
            "do": {
                "id": "hangup_34",
                "no": "hangup_34",
                "type": "yes",
                "command": "jump-to"
            },
            "key": "yes",
            "type": "yes" 
        },
        {
            
            "do": {
                "id": "hangup_34",
                "no": "hangup_34",
                "type": "yes",
                "command": "jump-to"
            },
            "key": "no",
            "type": "no"
        }
    ]
}
 */